package com.neusoft.neuiotms.dcom.model.problem;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Lob;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.validator.constraints.Length;

import com.neusoft.bizcore.web.jpa.model.AbstractAuditModel;
import com.neusoft.bizcore.web.jpa.model.Comment;

import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
@Entity
@Table(name = "neuiot_problem_handling")
@org.hibernate.annotations.Table(appliesTo = "neuiot_problem_handling", comment = "问题处理表")
public class ProblemHandling extends AbstractAuditModel {

    private static final long serialVersionUID = 1L;

    @Length(max = 255, message = "工作流TaskId不能超过{max}位")
    @Column(length = 255, nullable = false)
    @Comment("varchar(255) NOT NULL COMMENT '工作流TaskId'")
    private String taskId;

    @Length(max = 50, message = "工单号不能超过{max}位")
    @Column(length = 50, nullable = false)
    @Comment("varchar(50) NOT NULL COMMENT '工单号'")
    private String workOrderNum;

    @Lob
    @Column(columnDefinition = "longtext")
    @Comment("longtext COMMENT '问题原因'")
    private String problemCause;

    @Lob
    @Column(columnDefinition = "longtext")
    @Comment("longtext COMMENT '解决方案'")
    private String plan;

    @Column(nullable = false)
    @Comment("bit NOT NULL COMMENT '处理结果（0 否 1 是）'")
    private Boolean result = true;

    @Lob
    @Column(columnDefinition = "longtext")
    @Comment("longtext COMMENT '未完成原因'")
    private String unfinishedCause;

    /** 附件列表 **/
    @OneToMany(mappedBy = "problemHandling", cascade = CascadeType.ALL)
    private List<ProblemHandlingAttachment> attachments = new ArrayList<>();

}
